{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">官方消息</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('Platformmsg/add')}"
                   data-auth-edit="{:$auth->check('Platformmsg/edit')}"
                   data-auth-delete="{:$auth->check('Platformmsg/del')}">
            </table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="picTpl">
    <img style="max-width:100px; max-height:60px;" src="{{d.img_url}}" data-image="{{d.name}}">
</script>

<script type="text/html" id="barTool">

    {{# if(d.is_send==0){ }}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"
       data-full="true">编辑</a>
    {{# } }}
    <a class="layui-btn layui-btn-xs " data-open='{:url("edit2")}?id={{ d.id }}' data-title="复制并发布"
       data-full="true">复制并发布</a>

    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>


</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="启动|关闭" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
        };

        table.render({
            init: init,
            toolbar: ['refresh', 'add'],
            url: '{:url("index")}',
            cols: [
                [
                    //名称 水票背景图 所属商品分类 所属商品

                    {field: 'id', align: "center",width: '10%', title: 'ID'},
                    {field: 'title',align: "center", width: '10%', title: '发送标题', search:false},
                    {field: 'msg_cate', align: "center", width: '10%', title: '发送类型',search:false},
                    {field: 'is_time', align: "center", width: '10%', title: '是否定时'
                        , templet: function (d) {
                            if (d.is_time == 1) {
                                return '<span style="color: #00B83F">定时发送</span>';
                            }else{
                                return '<span style="color: #00a0e9">立即发送</span>';
                            }
                    }, selectList: {0:'立即发送',1:'定时发送'}
                    },
                    {field: 'is_send', align: "center", width: '10%', title: '是否发送',
                        templet: function (d) {
                            if (d.is_send == 1) {
                                return '<span style="color:#00B83F">已发送</span>';
                            }else{
                                return '<span style="color:orange">未发送</span>';
                            }
                        }, selectList: {0:'未发送',1:'已发送'}
                    },
                    {field: 'send_time', align: "center", width: '15%', title: '发送时间',search: 'range'},
                    {field: 'create_time', align: "center", width: '15%', title: '创建时间',search: 'range'},
                    {fixed: 'right', Width: 120,align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
    });
</script>
{/block}